<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
		<!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
		<meta name="renderer" content="webkit">
		<!--国产浏览器高速模式-->
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<title>电力通信管理系统</title>

		<!-- 公共样式 开始 -->
		<link rel="shortcut icon" href="images/favicon.ico"/>
		<link rel="bookmark" href="images/favicon.ico"/>
		<link rel="stylesheet" type="text/css" href="css/base.css">
		<link rel="stylesheet" type="text/css" href="css/iconfont.css">
		<script type="text/javascript" src="framework/jquery-1.11.3.min.js" ></script>
		<link rel="stylesheet" type="text/css" href="layui/css/layui.css">
	    <!--[if lt IE 9]>
	      	<script src="framework/html5shiv.min.js"></script>
	      	<script src="framework/respond.min.js"></script>
	    <![endif]-->
		<script type="text/javascript" src="layui/layui.js"></script>
		<!-- 滚动条插件 -->
		<link rel="stylesheet" type="text/css" href="css/jquery.mCustomScrollbar.css">
		<script src="framework/jquery-ui-1.10.4.min.js"></script>
		<script src="framework/jquery.mousewheel.min.js"></script>
		<script src="framework/jquery.mCustomScrollbar.min.js"></script>
		<script src="framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
		<!-- 公共样式 结束 -->

		<link rel="stylesheet" type="text/css" href="css/login.css">
		<script type="text/javascript" src="js/login.js"></script>
	</head>

	<body>

		<!--主体 开始-->
		<div class="login_main">
			<!--轮播图 开始-->
			<div class="layui-carousel lbt" id="loginLbt">
				<div carousel-item>
					<div class="item" style="background: url(images/lg01.jpg) no-repeat; background-size: cover;"></div>
					<div class="item" style="background: url(images/lg02.jpg) no-repeat; background-size: cover;"></div>
				</div>
			</div>
			<!--轮播图 结束-->
			<div class="logo" style="width: 250px;margin:0 auto;margin-top: 50px;margin-bottom: 10px">
				<img src="images/logo.png" />
				<div>
					<h1>电力通信管理系统</h1>
				</div>
			</div>
			<div class="form_tzgg" style="width: 500px;margin: 0 auto;">
				<div class="form">
						<div class="title">用户登录</div>
						<div class="con" onclick="getFocus(this)">
							<input type="text" name="managerid" id="managerid" lay-verify="managerid" placeholder="请输入您的用户名" autocomplete="off" class="layui-input">
						</div>
						<div class="con" onclick="getFocus(this)">
							<input type="password" name="manpassword" id="manpassword"  placeholder="请输入您的账户密码" autocomplete="off" class="layui-input">
						</div>
                        <div align="right">
                            <input type="checkbox"  name="savePW" id="savePW" value="1">&nbsp;记住密码
                        </div>
						<div class="but">
							<button class="layui-btn" id="loginBtn" lay-submit lay-filter="formDemo">登录</button>
						</div>
				</div>
				<script>
					if(window !== top){
						top.location.href=location.href;
					};
					$(document).ready(function(){
						window.sessionStorage.removeItem("user");
                        var id=window.localStorage.getItem("saveId");
                        var pw=window.localStorage.getItem("savePw");
                        if(id!==null&&pw!==null){
                            $("#managerid").val(id)
                            $("#manpassword").val(pw)
                            $("#savePW").attr("checked","checked")
                        }
					});
					$("#loginBtn").click(function () {
                        var managerid=$("#managerid").val();
						var manpassword=$("#manpassword").val();
						var savePW=false
                        $('#savePW:checked').each(function() {
                           savePW=true
                        });
						var body={
							"managerid":managerid,"manpassword":manpassword
						};
						$.ajax({
							type: "post",
							xhrFields: {
								withCredentials: true
							},
							crossDomain: true,
							dataType: "json",
							url: "http://localhost:8888/user/login",
							contentType: "application/json;charset=UTF-8",//指定消息请求类型
							data: JSON.stringify(body),//将js对象转成json对象
							success: function (data,status,xhr) {
								console.log(data)
								if (data.code == 0) {
									layer.msg("登录成功");
									window.sessionStorage.setItem("user",JSON.stringify(data.detail.user))
									window.sessionStorage.setItem("role",JSON.stringify(data.detail.role))
									window.sessionStorage.setItem("roles",JSON.stringify(data.detail.roles))
									window.location.assign("frame.html")
                                    if(savePW){
                                        window.localStorage.setItem("saveId",body.managerid)
                                        window.localStorage.setItem("savePw",body.manpassword)
                                    }
								} else {
									layer.msg(data.msg)
								}
							}
						})
					});
				</script>
				<div class="tzgg">
					<div class="title">通知公告</div>
					<div class="con">
						<ul>
							<li><span>05-01</span><a href="#" target="_blank">电力通信管理系统升级</a></li>

						</ul>
					</div>
				</div>
			</div>
		</div>
		<!--主体 结束-->
	</body>

</html>
